$(document).ready(function() {

});

// ------- Private vars -------
var jsReady = false;

// ------- functions called by ActionScript -------
// called to check if the page has initialized and JavaScript is available
function isReady() {
    return jsReady;
}

// called by the onload event of the <body> tag
function pageInit() {
    // Record that JavaScript is ready to go.
    jsReady = true;
    //alert(jsReady);
}

function getSWF(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        //alert('aa');
        return window[movieName];

    } else {
        //alert('bb');
        return document[movieName];
    }
}

sendstory = function(userid) {
    fusion2.dialog.sendStory({

        title : "热门社交应用《快照情缘》",

        img : "http://b250.photo.store.qq.com/psb?/V11PV0YF03rbId/i29qy7IkvF1vzHoMht8h6ugtS8YKw3sXsjHbtSILUPU!/b/dEs*EpWFGQAA&bo=yADIAAAAAAADACU!",

        summary : "有缘千里来“相”会，邂逅高富帅，约会百富美，一张快照，一世情缘！",

        msg : "我在《快照情缘》中遇到一位有缘人，看来今年桃花挡不住，嘿嘿！",

        button : "进入应用",

        source : "share=" + userid,

        context : "send-story-12345",

        onShown : function(opt) {
            //alert("Shown");
        },

        onSuccess : function(opt) {
            // opt.context：可选。opt.context为调用该接口时的context透传参数，以识别请求

            //alert("Succeeded: " + opt.context);

            userid = $("#userid").val();
            upxz(userid, '1');
        },

        onCancel : function(opt) {
            // opt.context：可选。opt.context为调用该接口时的context透传参数，以识别请求

            //alert("Cancelled: " + opt.context);
        },

        onClose : function(opt) {
            //alert("Closed");
        }
    });
}
invite = function(userid) {
    fusion2.dialog.invite({

        msg : "今年你的桃花运不错，强烈建议你来玩《快照情缘》~邂逅有缘人！",

        //img : "",

        source : "share=" + userid,

        context : "invite",

        onSuccess : function(opt) {
            //alert("邀请成功");
            userid = $("#userid").val();
            upxz(userid, '2');
        },

        onCancel : function(opt) {
            //alert("邀请取消");
        },

        onClose : function(opt) {
            //alert("邀请关闭");
        }
    });

}
sayhello = function(msg) {
    alert("hello," + msg);
}
flashsync = function() {
    var isIE = document.all && window.external;
    var swfId = "swf_" + ( isIE ? "ie" : "other");
    document.getElementById(swfId).sync();
}
upxz = function(id, tp) {
    $.post("?a=upxz", {
        userid : id,
        type : tp
    }, function(data, status) {
        alert(data);
        flashsync();
    });
}
lahei = function(id) {
    $.post("?c=bops&a=lahei", {
        photoid : id
    }, function(data, status) {
        if (data == 'ok') {
            location.reload();
        } else {
            alert(data);
        }
    });
}
likes = function(photoid, likeid, submitid) {
    //alert("like");
    $.post("?a=like", {
        likeid : likeid,
        photoid : photoid,
        submitid : submitid
    }, function(data, status) {
        if (data == 'ok') {
            location.reload();
        } else {
            alert(data);
        }
    })
};
